package com.demo.passenger.sys.permission.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.demo.passenger.sys.permission.entity.SysPermission;
import com.demo.passenger.sys.permission.service.ISysPermissionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author weifucheng
 * @since 2019-07-13
 */
@Controller
@RequestMapping("/sys/permission/permission")
public class SysPermissionController {
    @Autowired
    ISysPermissionService sysPermissionService;

    @RequestMapping("/listByParams")
    @ResponseBody
    public List<SysPermission> listByParams(Page<SysPermission> page, SysPermission sysPermission){
        return sysPermissionService.listByParams(page,sysPermission);
    }

    @RequestMapping("/listAll")
    @ResponseBody
    public List<SysPermission> listAll(){
        return sysPermissionService.list();
    }

    @RequestMapping("/save")
    @ResponseBody
    public Boolean save(SysPermission sysPermission){
        return sysPermissionService.saveOrUpdate(sysPermission);
    }

    @RequestMapping("/update")
    @ResponseBody
    public Boolean update(SysPermission sysPermission){
        return sysPermissionService.saveOrUpdate(sysPermission);
    }

    @RequestMapping("/delete")
    @ResponseBody
    public Boolean delete(SysPermission sysPermission){
        return sysPermissionService.removeById(sysPermission.getId());
    }
}
